class Quadruple:
    def __init__(self, op, arg1, arg2, result):
        self.op = op
        self.arg1 = arg1
        self.arg2 = arg2
        self.result = result

    def __str__(self):
        """
        返回表达式对象的字符串表示形式。
        
        Args:
            无
        
        Returns:
            str: 表达式对象的字符串表示形式，格式为"(op, arg1, arg2, result)"。
        
        """
        return f"({self.op}, {self.arg1}, {self.arg2}, {self.result})"


# 示例Python代码
python_code = """
if (x>0) :
    Y = X * X
else:
    Y = X + X
"""
def generate_quadruples(python_code):
    # 这里只是一个示例，实际的代码需要解析Python语法树
    # 并且生成对应的四元式
    quadruples = []
    lines = python_code.strip().split('\n')
    for line in lines:
        if 'if' in line:
            # 假设if语句的形式为：if condition: goto label
            parts = line.split()
            condition = parts[1].strip('()')
            label = parts[3].strip(':')
            quadruples.append(Quadruple('if', condition, 'goto', label))
        elif 'else' in line:
            # 假设else语句的形式为：goto label1; label: goto label2
            quadruples.append(Quadruple('goto', label, '', ''))
            label = lines[lines.index(line) + 1].strip().split(':')[1].strip()
            quadruples.append(Quadruple('goto', label, '', ''))
    return quadruples



# 生成四元式
quadruples = generate_quadruples(python_code)
for q in quadruples:
    print(q)